<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
selection_test(
    [
        '<div style="user-select:none">',
            '<table contenteditable>',
            '</table>',
        '</div>'
    ],
    selection => {
       const document = selection.document;
       // We should set HTML content for this test using innerHTML,
       // else HTML parser moves '<h1>' outside '<table>'.
       document.querySelector('table').innerHTML = '<h1>foo</h1><img>bar';
       const bar = document.querySelector('img').nextSibling;
       selection.collapse(bar, 3);
       document.execCommand('insertParagraph');
    },
    [
        '<div style="user-select:none">',
            '<table contenteditable>',
            '<h1>foo</h1><img>bar|',
            '</table>',
        '</div>'
    ],
    'Should not crash when insertParagraph on nonselectable node boundary');
</script>

